/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_SSAP_SERVER_PARCEL_H
#define SLE_SSAP_SERVER_PARCEL_H

#include <cstdint>
#include <memory>
#include "parcel.h"
#include "sle_ssap_server_config.h"
#include "sle_ssap_common_parcel.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class SsapServerPropertyParam : public Parcelable {
public:
    SsapServerPropertyParam() = default;
    explicit SsapServerPropertyParam(const SsapsPropertyParam &param);
    ~SsapServerPropertyParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerPropertyParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsPropertyParam(SsapsPropertyParam &param) const;
    static SleErrorCode CheckSsapsPropertyParam(const SsapsPropertyParam &param);

public:
    Uuid uuid_;
    uint16_t permissions_;
    uint32_t opIndication_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapServerDescriptorParam : public Parcelable {
public:
    SsapServerDescriptorParam() = default;
    explicit SsapServerDescriptorParam(const SsapsDescriptorParam &param);
    ~SsapServerDescriptorParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerDescriptorParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsDescriptorParam(SsapsDescriptorParam &param) const;
    static SleErrorCode CheckSsapsDescriptorParam(const SsapsDescriptorParam &param);

public:
    Uuid uuid_;
    uint16_t permissions_;
    uint32_t opIndication_;
    uint8_t type_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapServerSendRspParam : public Parcelable {
public:
    SsapServerSendRspParam() = default;
    explicit SsapServerSendRspParam(const SsapsSendRspParam &param);
    ~SsapServerSendRspParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerSendRspParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsSendRspParam(SsapsSendRspParam &param) const;
    static SleErrorCode CheckSsapsSendRspParam(const SsapsSendRspParam &param);

public:
    uint16_t requestId_;
    uint8_t status_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapServerNotifyParam : public Parcelable {
public:
    SsapServerNotifyParam() = default;
    explicit SsapServerNotifyParam(const SsapsNotifyParam &param);
    ~SsapServerNotifyParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerNotifyParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsNotifyParam(SsapsNotifyParam &param) const;
    static SleErrorCode CheckSsapsNotifyParam(const SsapsNotifyParam &param);

public:
    uint16_t handle_;
    uint8_t type_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapServerNotyfyByUuidParam : public Parcelable {
public:
    SsapServerNotyfyByUuidParam() = default;
    explicit SsapServerNotyfyByUuidParam(const SsapsNotyfyByUuidParam &param);
    ~SsapServerNotyfyByUuidParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerNotyfyByUuidParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsNotyfyByUuidParam(SsapsNotyfyByUuidParam &param) const;
    static SleErrorCode CheckSsapsNotyfyByUuidParam(const SsapsNotyfyByUuidParam &param);

public:
    Uuid uuid_;
    uint16_t startHandle_;
    uint16_t endHandle_;
    uint8_t type_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};

class SsapServerReqReadCbParam : public Parcelable {
public:
    SsapServerReqReadCbParam() = default;
    explicit SsapServerReqReadCbParam(const SsapsReqReadCbParam &param);
    ~SsapServerReqReadCbParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerReqReadCbParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsReqReadCbParam(SsapsReqReadCbParam &value) const;

public:
    uint16_t requestId_;
    uint16_t handle_;
    uint8_t type_;
    bool needRsp_;
    bool needAuthorize_;
};

class SsapServerReqWriteCbParam : public Parcelable {
public:
    SsapServerReqWriteCbParam() = default;
    explicit SsapServerReqWriteCbParam(const SsapsReqWriteCbPara &param);
    ~SsapServerReqWriteCbParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static SsapServerReqWriteCbParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSsapsReqWriteCbPara(SsapsReqWriteCbPara &value) const;

public:
    uint16_t requestId_;
    uint16_t handle_;
    uint8_t type_;
    bool needRsp_;
    bool needAuthorize_;
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_SSAP_SERVER_PARCEL_H